package util;

import dao.PageDao;
import dao.impl.PageDaoImpl;
import pojo.Page;

import java.util.ArrayList;

public class PageUtils {
    private static PageDao pageDao = new PageDaoImpl();

    public static <T> Page<T> page(ArrayList<T> list, Integer currentPage, Integer rows, int total) {
        Page<T> page = new Page<>();
        page.setCurrentPage(currentPage);
        page.setRows(rows);
        page.setTotal(total);
        Integer start = 0;
        start = (currentPage - 1) * rows;
        page.setList(list);
        Integer totalPage = 0;
        totalPage = total % rows == 0 ? total / rows : (total / rows) + 1;
        page.setTotalPage(totalPage);
        return page;

    }
}
